# -*- coding: utf-8 -*-
# @Time    : 2022/5/19 15:31
# @Author  : zyw
# @Email   : panda_kings@163.com
# @File    : tasks.py
# 此处定义任务
import traceback
import logging
from celery_tasks.main import celery_app
from ronglian_sms_sdk import SmsSDK


accId = '8a216da87e7baef8017f20f1079b177d'
accToken = 'e09ca3c4230848afa6097d062188daaf'
appId = '8a216da87e7baef8017f20f108c71784'

# 任务的名字
@celery_app.task
def phone_code(mobile, code):
    logging.info('phone_code:{}'.format(locals()))
    resp = 0
    try:
        sdk = SmsSDK(accId, accToken, appId)
        datas = (code, '5')
        resp = sdk.sendMessage('1', mobile, datas)
        print("发送的结果>>>", resp)
    except:
        error = traceback.format_exc()
        logging.error('phone_code error:{}'.format(error))
    return resp





